package com.ls.controller.sms;

import com.ls.controller.sms.model.SmsModel;
import com.ls.service.ISmsService;
import com.ls.utils.ResultData;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @ClassName SmsController
 * @Description 发送短信相关接口
 *
 * @author pengyu
 * @since 2024-06-28
 */
@Api(value = "发送短信相关接口", tags = "发送短信相关接口")
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/sms")
public class SmsController {
    private final ISmsService service;
    @PostMapping(value = "send")
    public ResultData sendSms(@Valid @RequestBody SmsModel model) {
        log.info("发送短信传入数据:={}", model);
        return service.sendSms(model);
//        try {
//            // 调用短信工具类发送短信
//            ResultData result = SmsPyUtil.sendCommonSms(model);
//            if (result.isSuccess()) {
//                log.info("短信发送成功，手机号：{}", model.getMobile());
//            } else {
//                log.error("短信发送失败，手机号：{}", model.getMobile());
//            }
//            return result;
//        } catch (Exception e) {
//            log.error("短信发送异常，手机号：{}，错误信息：{}", model.getMobile(), e.getMessage());
//            return ResultData.failure("系统异常，请稍后重试");
//        }
    }
}
